﻿
Imports System.Data.SqlClient
Imports QuanLyBanChau.LoaiChau
Public Class LoaiChau_dao
    Public Shared Sub insertLoaiChaudao(ByVal LoaiChau As LoaiChau)
        Dim conn As SqlConnection
        Dim cmd As SqlCommand
        Dim para As SqlParameter
        conn = dataprovider.Connection()
        cmd = New SqlCommand("insert_LoaiChau", conn)
        cmd.CommandType = CommandType.StoredProcedure

        para = New SqlParameter("@Maloai", SqlDbType.VarChar, 10)
        para.Value = LoaiChau.Maloai
        cmd.Parameters.Add(para)

        para = New SqlParameter("@Tenloai", SqlDbType.NVarChar, 100)
        para.Value = LoaiChau.Tenloai
        cmd.Parameters.Add(para)

        cmd.ExecuteNonQuery()
        cmd.Dispose()
        conn.Close()
    End Sub


    Public Shared Sub DeleteLoaiChaudao(ByVal Maloai)
        Dim conn As SqlConnection
        Dim cmd As SqlCommand
        Dim para As SqlParameter
        conn = dataprovider.Connection()
        cmd = New SqlCommand("Delete_LoaiChau", conn)
        cmd.CommandType = CommandType.StoredProcedure
        para = New SqlParameter("@Maloai", SqlDbType.VarChar, 10)
        para.Value = Maloai
        cmd.Parameters.Add(para)
        cmd.ExecuteNonQuery()
        cmd.Dispose()
        conn.Close()
    End Sub
    Public Shared Function Get_LoaiChaudao()
        Dim conn As SqlConnection
        conn = dataprovider.Connection()
        Dim da As New SqlDataAdapter
        Dim dt As New DataTable
        da.SelectCommand = New SqlCommand
        da.SelectCommand.Connection = conn
        da.SelectCommand.CommandType = CommandType.StoredProcedure
        da.SelectCommand.CommandText = "Get_LoaiChau"
        da.Fill(dt)
        Return dt
    End Function
    Public Shared Sub UpdateLoaiChaudao(ByVal LoaiChau As LoaiChau)
        Dim conn As SqlConnection
        Dim cmd As SqlCommand
        Dim para(7) As SqlParameter
        conn = dataprovider.Connection()
        cmd = New SqlCommand("Update_LoaiChau", conn)
        cmd.CommandType = CommandType.StoredProcedure
        para(0) = New SqlParameter("@Maloai", SqlDbType.VarChar, 10)
        para(0).Value = LoaiChau.Maloai
        cmd.Parameters.Add(para(0))
        para(1) = New SqlParameter("@Tenloai", SqlDbType.NVarChar, 10)
        para(1).Value = LoaiChau.Tenloai
        cmd.Parameters.Add(para(1))

        cmd.ExecuteNonQuery()
        cmd.Dispose()
        conn.Close()
    End Sub

End Class
